package repository

import (
	"context"
	"webook/internal/repository/cache"
)

var (
	ErrCodeSendTooMany     = cache.ErrSetCodeBusy
	ErrCodeSendSystemError = cache.ErrSetCodeSystemError
	ErrCodeVerifyTooMany   = cache.ErrVarifyCodeTooMany
	ErrCodeVerifyInvalid   = cache.ErrVarifyCodeInvalid
)

type CodeRepository struct {
	cache *cache.CodeCache
}

func NewCodeRepository(cache *cache.CodeCache) *CodeRepository {
	return &CodeRepository{
		cache: cache,
	}
}

func (r *CodeRepository) Set(ctx context.Context, biz string, phone string, code string) error {
	return r.cache.Set(ctx, biz, phone, code)
}

func (r *CodeRepository) Store(ctx context.Context, biz string, phone string, code string) error {
	return r.cache.Set(ctx, biz, phone, code)
}

func (r *CodeRepository) Verify(ctx context.Context, biz string, phone string, code string) error {
	return r.cache.Verify(ctx, biz, phone, code)
}
